// 使用：import userInfoStore from "@/store/modules/userinfo"; const userInfo = userInfoStore()
import { defineStore } from "pinia";
import api from "@/api/index";
const userInfoStore = defineStore("userInfo", {
  persist: true, // 开启数据持久化
  state: () => ({
    id: "",
    username: "",
    realname: "",
    phone: "",
    customerId: "",
    customerName: "",
    mobile: "",
    nickname: "",
    userType: "",
    userIdentity: "",
    isSmartEnergy: true,
  }),
  actions: {
    // 字典查询接口
    async getCustomer() {
      const { data } = await api.getUserApi({});
      // if (code == 200) {
        this.id = data.id;
        this.username = data.username;
        this.realname = data.realname;
        this.phone = data.phone;
        this.customerId = data.customerId;
        this.customerName = data.customerName;
        this.mobile = data.mobile;
        this.nickname = data.nickname;
        this.userType = data.userType;
        this.userIdentity = data.userIdentity;
        this.isSmartEnergy = data.isSmartEnergy;
      // }
    },
  },
});
export default userInfoStore;
